<template>
	<view class="edit-layout">
		<view class="textarea-box">
			<textarea class="textarea" auto-height placeholder="输入经营地址" placeholder-style="font-size: 28rpx;" v-model="address" />
		</view>
		<view class="submit-btn save-btn" @tap="saveAction">保存</view>
	</view>
</template>

<script setup>
	import { useUserStore } from '@/stores'
	import { ref } from 'vue'
	import { editMerchantInfo,getUserInfo} from '@/config/api.js';
	const userStore = useUserStore()
	//经营地址
	const address = ref('')
	address.value = userStore.user.merAddress
	//保存
	const saveAction = ()=>{
		if(uni.$u.test.isEmpty(uni.$tools.clearSpaceAndEnter(address.value))){
			uni.$tools.showToast('请输入经营地址')
			return
		}
		editMerchantInfo({bussinessAddr:uni.$tools.clearSpaceAndEnter(address.value)}).then(res=>{
			updateUserInfo()
			uni.navigateBack()
			uni.$tools.showToast('已提交修改')
		}).catch(err=>{
			
		})
	}
	//获取用户信息
	const updateUserInfo = ()=> {
		getUserInfo().then(res=>{
			userStore.user = userInfo.result
		}).catch(err=>{
		})
	}
	
</script>

<style lang="scss" scoped>
	.edit-layout {
		.textarea-box {
			background-color: #fff;
			padding: 30rpx;
			.textarea {
				font-size: 28rpx;
				color: $xh-title-color;
			}
		}
		.save-btn {
			width: 690rpx;
			margin: 0 auto;
			margin-top: 100rpx;
		}
	}
</style>